package polymorphic1;

/**
 * @classname:MonsterTest
 * @description:
 * @author: Mr.Z
 * @date: 2020/11/29 19:24
 * @version: 0.1
 * @since:1.8
 */
public class MonsterTest {
    public static void main(String[] args) {

        Monster[] monsters = new Monster[2];
        Monster goblin = new Goblin("哥布林","100","80","20");
        Monster cat = new Goblin("猫妖","100","80","20");
        monsters[0] = goblin;
        monsters[1] = cat;
        for (int i = 0; i < 10; i++) {
            monsters[0].move();
            monsters[0].attack();
            monsters[1].move();
            monsters[1].attack();
        }


    }

    public void move(Monster monster){
        monster.move();
        //一会试试cat方法变成private行不
    }
    public void attack(Monster monster){
        monster.attack();
    }
}
